{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "e9735fe0-f1ac-430f-826e-f95396666501",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<html>\\(\\displaystyle 6.62607015 \\times 10^{-34}\\)</html>"
      ],
      "text/latex": [
       "$\\displaystyle 6.62607015 \\times 10^{-34}$"
      ],
      "text/plain": [
       "6.62607015e-34"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<html>\\(\\displaystyle 1.602176634 \\times 10^{-19}\\)</html>"
      ],
      "text/latex": [
       "$\\displaystyle 1.602176634 \\times 10^{-19}$"
      ],
      "text/plain": [
       "1.602176634e-19"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<html>\\(\\displaystyle 299792458.0\\)</html>"
      ],
      "text/latex": [
       "$\\displaystyle 299792458.0$"
      ],
      "text/plain": [
       "299792458.0"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "(6.62607015e-34, 'J Hz^-1', 0.0)"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 物理常数调用\n",
    "from scipy import constants as const\n",
    "show(const.h)\n",
    "show(const.e)\n",
    "show(const.c)\n",
    "# 这里可以看更多\n",
    "const.physical_constants[\"Planck constant\"] \n",
    "# 上面这个是量子力学的，咱这里要电动力学的"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7c086807-c01a-4522-a0de-62c27b46f5f0",
   "metadata": {},
   "source": [
    "热统的常数，真空中的……好吧直接看后面常数表\n",
    "\n",
    "* 真空中光速\n",
    "* 普朗克常量\n",
    "* 约化普朗克常量\n",
    "* 元电荷\n",
    "* 阿伏伽德罗常量\n",
    "* 摩尔气体常量\n",
    "* 玻尔兹曼常量\n",
    "* 理想气体的摩尔体积（标准状态）\n",
    "* 斯特藩-玻尔兹曼常量（干什么用的？）\n",
    "* 维恩位移定律常量\n",
    "* 引力常量\n",
    "* 真空磁导率\n",
    "* 真空电容率\n",
    "* 电子质量\n",
    "* 电子比荷\n",
    "* 质子质量\n",
    "* 中子质量\n",
    "* 里德伯常量\n",
    "* 精细结构常数\n",
    "* 精细结构常数的倒数\n",
    "* 玻尔磁子\n",
    "* 核磁子\n",
    "* 波尔半径\n",
    "* 康普顿波长\n",
    "* 原子质量常量"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 101,
   "id": "47dc3138-a9b9-44b6-87a7-695ae0947b3e",
   "metadata": {},
   "outputs": [],
   "source": [
    "def print_const(中文名,符号,英文常量索引):\n",
    "    result = const.physical_constants[英文常量索引]\n",
    "    print(中文名+\"(\"+符号+\")：\"+'{:e}'.format(result[0])+' ('+result[1]+')')\n",
    "\n",
    "def print_consts(arg_list):\n",
    "    for i in arg_list:\n",
    "        print_const(i[0],i[1],i[2])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 102,
   "id": "c1afffbb-0976-4ece-89b9-d22a6166e042",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "真空中光速(c)：2.997925e+08 (m s^-1)\n",
      "普朗克常量(h)：6.626070e-34 (J Hz^-1)\n",
      "约化普朗克常量(h/2π)：1.054572e-34 (J s)\n",
      "元电荷(e)：1.602177e-19 (C)\n",
      "阿伏伽德罗常量(N_A)：6.022141e+23 (mol^-1)\n",
      "摩尔气体常量(R)：8.314463e+00 (J mol^-1 K^-1)\n",
      "玻尔兹曼常量(k)：1.380649e-23 (J K^-1)\n"
     ]
    }
   ],
   "source": [
    "print_consts([\n",
    "    (\"真空中光速\",\"c\",\"speed of light in vacuum\"),\n",
    "    (\"普朗克常量\",\"h\",\"Planck constant\"),\n",
    "    (\"约化普朗克常量\",\"h/2π\",\"reduced Planck constant\"),\n",
    "    (\"元电荷\",\"e\",\"elementary charge\"),\n",
    "    (\"阿伏伽德罗常量\",\"N_A\",\"Avogadro constant\"),\n",
    "    (\"摩尔气体常量\",\"R\",\"molar gas constant\"),\n",
    "    (\"玻尔兹曼常量\",\"k\",\"Boltzmann constant\"),\n",
    "])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 103,
   "id": "b3e063df-5cb0-4c51-8072-d06d1b4c627b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "理想气体的摩尔体积（标准状态）(V_m)：2.241397e-02 (m^3 mol^-1)\n",
      "斯特藩-玻尔兹曼常量(σ)：5.670374e-08 (W m^-2 K^-4)\n",
      "维恩位移定律常量(b)：2.897772e-03 (m K)\n",
      "引力常量(G)：6.674300e-11 (m^3 kg^-1 s^-2)\n",
      "真空磁导率(μ_0)：1.256637e-06 (N A^-2)\n",
      "真空电容率(ε)：8.854188e-12 (F m^-1)\n"
     ]
    }
   ],
   "source": [
    "print_consts([\n",
    "    (\"理想气体的摩尔体积（标准状态）\",\"V_m\",'molar volume of ideal gas (273.15 K, 101.325 kPa)'),\n",
    "    (\"斯特藩-玻尔兹曼常量\",\"σ\",\"Stefan-Boltzmann constant\"), # 这东西干什么用的？\n",
    "    (\"维恩位移定律常量\",\"b\",\"Wien wavelength displacement law constant\"),\n",
    "    (\"引力常量\",\"G\",\"Newtonian constant of gravitation\"),\n",
    "    (\"真空磁导率\",\"μ_0\",\"vacuum mag. permeability\"),\n",
    "    (\"真空电容率\",\"ε\",\"vacuum electric permittivity\"),\n",
    "])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 105,
   "id": "6e6fd386-80bd-4a41-9e5b-d310b974ba75",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "电子质量(m_e)：9.109384e-31 (kg)\n",
      "电子比荷(-e/m_e)：-1.758820e+11 (C kg^-1)\n",
      "质子质量(m_p)：1.672622e-27 (kg)\n",
      "中子质量(m_n)：1.674927e-27 (kg)\n",
      "原子质量常量(m_u)：1.660539e-27 (kg)\n"
     ]
    }
   ],
   "source": [
    "print_consts([\n",
    "    (\"电子质量\",\"m_e\",'electron mass'),\n",
    "    (\"电子比荷\",\"-e/m_e\",\"electron charge to mass quotient\"), \n",
    "    (\"质子质量\",\"m_p\",\"proton mass\"),\n",
    "    (\"中子质量\",\"m_n\",\"neutron mass\"),\n",
    "    (\"原子质量常量\",\"m_u\",\"unified atomic mass unit\"),\n",
    "])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 121,
   "id": "5a93082e-95b1-4027-a652-45ef3b06b391",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "里德伯常量(R_∞)：1.097373e+07 (m^-1)\n",
      "精细结构常数(α)：7.297353e-03 ()\n",
      "精细结构常数的倒数(α^-1)：1.370360e+02 ()\n",
      "波尔磁子(μ_B)：9.274010e-24 (J T^-1)\n",
      "核磁子(μ_N)：5.050784e-27 (J T^-1)\n",
      "波尔半径(a_0)：5.291772e-11 (m)\n",
      "康普顿波长(λ_C)：2.426310e-12 (m)\n"
     ]
    }
   ],
   "source": [
    "print_consts([\n",
    "    (\"里德伯常量\",\"R_∞\",'Rydberg constant'),\n",
    "    (\"精细结构常数\",\"α\",\"fine-structure constant\"), \n",
    "    (\"精细结构常数的倒数\",\"α^-1\",\"inverse fine-structure constant\"),\n",
    "    (\"波尔磁子\",\"μ_B\",\"Bohr magneton\"),\n",
    "    (\"核磁子\",\"μ_N\",\"nuclear magneton\"),\n",
    "    (\"波尔半径\",\"a_0\",\"Bohr radius\"),\n",
    "    (\"康普顿波长\",\"λ_C\",\"Compton wavelength\"),\n",
    "])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 122,
   "id": "5730381c-057d-4050-8931-905f4122f2e5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Compton wavelength : (2.42631023867e-12, 'm', 7.3e-22)\n",
      "Compton wavelength over 2 pi : (3.8615926764e-13, 'm', 1.8e-22)\n",
      "muon Compton wavelength : (1.17344411e-14, 'm', 2.6e-22)\n",
      "muon Compton wavelength over 2 pi : (1.867594308e-15, 'm', 4.2e-23)\n",
      "neutron Compton wavelength : (1.31959090581e-15, 'm', 7.5e-25)\n",
      "neutron Compton wavelength over 2 pi : (2.1001941536e-16, 'm', 1.4e-25)\n",
      "proton Compton wavelength : (1.32140985539e-15, 'm', 4e-25)\n",
      "proton Compton wavelength over 2 pi : (2.10308910109e-16, 'm', 9.7e-26)\n",
      "tau Compton wavelength : (6.97771e-16, 'm', 4.7e-20)\n",
      "tau Compton wavelength over 2 pi : (1.11056e-16, 'm', 1e-20)\n",
      "reduced Compton wavelength : (3.8615926796e-13, 'm', 1.2e-22)\n",
      "reduced muon Compton wavelength : (1.867594306e-15, 'm', 4.2e-23)\n",
      "reduced neutron Compton wavelength : (2.1001941552e-16, 'm', 1.2e-25)\n",
      "reduced proton Compton wavelength : (2.10308910336e-16, 'm', 6.4e-26)\n",
      "reduced tau Compton wavelength : (1.110538e-16, 'm', 7.5e-21)\n"
     ]
    }
   ],
   "source": [
    "#搜索工具\n",
    "for i in const.physical_constants:\n",
    "    if 'wave' in i: #名称搜索\n",
    "        if 'm' == const.physical_constants[i][1]: #单位搜索\n",
    "            print(i+' : '+str(const.physical_constants[i]))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "SageMath 10.5",
   "language": "sage",
   "name": "sagemath"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
